﻿@{
    Layout = null;
}

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>客商数据信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/js/layui/css/layui.css" rel="stylesheet" />
    <link href="~/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/X-admin/js/jquery.min.js"></script>
    <script src="~/X-admin/js/xadmin.js"></script>
    <script src="~/js/framework/sysframework.js"></script>
    <script src="~/js/framework/Common.js"></script>
    <script src="~/js/layui/layui.js"></script>

    
</head>
<body>
    <div class="layui-fluid">
        <div id="bDiv">
        </div>

        <div style="float:left">
            <div id="treeNav" class="demo-tree demo-tree-box" style="width: 200px; height: 500px; overflow: scroll;float:left;"></div>

        </div>
        <div style="float:left;width:78%;">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" name="qForm" id="qForm">

                        <div class="layui-inline layui-show-xs-block">

                            <input type="text" name="cuCode" placeholder="请输入编码" autocomplete="off" class="layui-input" id="cuCode">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="cuName" placeholder="请输入名称" autocomplete="off" class="layui-input" id="cuName">
                          
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach" id="deptSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                        <input type="hidden" name="cuType" id="cuType" />
                        <input type="hidden" name="dataType" id="dataType" />
                    </form>
                </div>

           
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-hide" id="list" lay-filter="list"></table>
                </div>
            </div>


        </div>

    </div>
</body>
</html>

<script type="text/javascript">
    
    function loadData() {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                    { field: 'id', title: 'ID', width: 80 }
                    , { field: 'cuCode', title: '编码', width: 250 }
                    , { field: 'cuName', title: '名称', width: 250 }
                    , { field: 'arddress', title: '地址', width: 450 }
                ]], done: function (res, curr, count) {
                    $("[data-field='id']").css('display', 'none');//隐藏列
                }
                , url: "../Basic/GetDataList?condition=" + conditon + "&dataType=Cu" 
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 30, 50]
                , limit: 15 //每页默认显示的数量
            });


        });
    }

    var dataType = "";
    $(function () {
        dataType = getUrlVariable("dataType");
        $("input[ name='dataType']").val(dataType);

        webCode = getUrlVariable("menuCode");
        BannerData(webCode, "bDiv");

        $.ajax({
            url: "../Basic/CuClassNavigation", //string dataType
            data: { dataType: dataType },
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.result) {
                    loadTree(data.data);
                } else {
                    layer.msg(data.message);
                }
            }
        });
    })
    function loadTree(data) {//客商大类列表
        console.log(data);
        var tree = layui.tree;
        var layer = layui.layer;
        var util = layui.util;
        //开启节点操作图标
        tree.render({
            elem: '#treeNav'
            , data: data
            , click: function (obj) {
                $("input[ name='cuType']").val(obj.data["id"]);
                loadData();
      
            }
        });
    }

    
    /**
     * 客商数据同步
     */
    function syncData() {
        $.ajax({
            url: "../System/SyncData",
            data: { syncCode: dataType },
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.result) {
                    layer.msg("同步执行成功");
                } else {
                    layer.msg(data.message);
                }
            }
        });
    }

</script>